<extend name="Public/baseConf"/>
<block name="breadcrumb"> 
	<div class="row wrapper border-bottom white-bg page-heading">
	    <div class="col-lg-6">
	        <h2><present name="data">[ {$data.title} ] 子</present>菜单管理 </h2>
	        <ol class="breadcrumb">
	            <li><a href="{:U('index/index')}">首页</a></li>
	            <li class="active">
	                <strong><a href="{:U('menu/index')}">菜单管理 </a></strong>
	            </li>
	        </ol>
	    </div>
	    <div class="col-lg-6">
            <div class="title-action">
				<span class="block pull-left">
					<a class="btn btn-white" href="{:U('add',array('pid'=>I('get.pid',0)))}">
						<i class="text-navy fa fa-pencil align-top"></i>新增
					</a>
			        <button class="btn btn-white ajax-post" url="{:U('del')}" target-form="ids">
						<i class="text-danger fa fa-trash align-top"></i>删除
					</button>
					<button class="btn btn-white ajax-post" url="{:U('import',array('pid'=>I('get.pid',0)))}" target-form="ids">
						<i class="fa fa-flag"></i>导入
					</button>
					<button class="btn btn-white ajax-post" url="{:U('sort',array('pid'=>I('get.pid',0)),'')}" target-form="ids">
						<i class="fa fa-flag"></i>排序
					</button>
				</span>
				<div class="input-group">
					<input type="text" class="form-control search-input" name="title" value="{:I('title')}" placeholder="请输入菜单名称"> 
					<span class="input-group-btn"> 
						<a id="search" type="button" url="__SELF__" class="btn btn-primary"><i class="fa fa-search green bigger-125"></i></a> 
	                </span>
	            </div>
            </div>
        </div>
	</div>
</block>
<block name="body">
	<div class="row">
            <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>配置管理列表</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="table-responsive">
                    <form class="ids">
		                  <table class="table table-striped table-bordered table-hover dataTables-example" >
			                  <thead>
			                  <tr>
									<th class="row-selected row-selected">
									<label><input type="checkbox" class="check-all" /><span class="lbl"></span></label></th>
									<th class="center">图标</th>
				                    <th class="center">ID</th>
				                    <th class="center">名称</th>
				                    <th class="center">上级菜单</th>
				                    <!-- <th class="center">分组</th> -->
				                    <th class="center">URL</th>
				                    <th class="center">排序</th>
				                    <th class="center">开发</th>
				                    <th class="center">隐藏</th>
				                    <th class="center">类别</th>
				                    <th class="center">操作</th>
									<th></th>
			                  </tr>
			                  </thead>
			                  <tbody>
									<notempty name="list">
									<volist name="list" id="menu">
									<tr>
							            <td class="center">
											<label>
												<input type="checkbox" class="ids row-selected" name="id[]" value="{$menu.id}"/>
												<span class="lbl"></span>
											</label>
										</td>
				                        <td class="center">
				                        	<i class='{$menu.iconcss} bigger-130 center'></i>
				                        </td>
				                        <td>{$menu.id}</td>
				                        <td>
				                            <a href="{:U('index?pid='.$menu['id'])}">{$menu.title}</a>
				                        </td>
				                        <td class="center">{$menu.up_title|default='无'}</td>
				                        <!-- <td>{$menu.group}</td> -->
				                        <td>{$menu.url}</td>
				                        <td class="center">{$menu.sort}</td>
				                        <td class="center">
				                            <a href="{:U('toogleDev',array('id'=>$menu['id'],'value'=>abs($menu['is_dev']-1)))}" class="ajax-get">
				                            {$menu.is_dev_text}
				                            </a>
				                        </td>
				                        <td class="center">
				                            <a href="{:U('toogleHide',array('id'=>$menu['id'],'value'=>abs($menu['hide']-1)))}" class="ajax-get">
				                            {$menu.hide_text}
				                            </a>
				                        </td>
				                        <td>{$menu.issysfunction_text}</td>
				                        <td class="center">
				                        	<a title="编辑" class="green" href="{:U('edit?id='.$menu['id'])}"><i class='menu-icon text-primary fa fa-pencil bigger-130'></i></a>&nbsp;&nbsp;
				                        	<if condition="$menu.issysfunction eq 0">
							                <a title="删除" class="red ajax-get" href="{:U('del?id='.$menu['id'])}"><i class="menu-icon text-danger fa fa-trash-o bigger-130"></i></a>
							                </if>
				                        </td>
							            <td></td>
									</tr>
									</volist>
									<else/> 
									<td colspan="11" class="text-center"> aOh! 暂时还没有内容! </td>
									</notempty>
			                  </tbody>
		                  </table>
		            </form>
		            <div class="page pull-right">
				     	{$_page}
			 		</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="script">
    <script type="text/javascript">
        $(function() {
            //搜索功能
            $("#search").click(function() {
                var url = $(this).attr('url');
                var query = $('.input-group').find('input').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });
            //回车搜索
            $(".search-input").keyup(function(e) {
                if (e.keyCode === 13) {
                    $("#search").click();
                    return false;
                }
            });
            //点击排序
        	$('.list_sort').click(function(){
        		var url = $(this).attr('url');
        		var ids = $('.ids:checked');
        		var param = '';
        		if(ids.length > 0){
        			var str = new Array();
        			ids.each(function(){
        				str.push($(this).val());
        			});
        			param = str.join(',');
        		}

        		if(url != undefined && url != ''){
        			window.location.href = url + '/ids/' + param;
        		}
        	});
        });
    </script>
</block>